﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI;
using System.IO;
using System.Web;

namespace V5_EaspLibs.Utility
{
    public class ViewManager : UserControl
    {
        private Page m_pageHolder;
        /// <summary>
        /// 载入控件
        /// </summary>
        /// <param name="path">控件地址</param>
        /// <returns></returns>
        public Control LoadViewControl(string path)
        {
            this.m_pageHolder = new Page();
            return this.m_pageHolder.LoadControl(path);
        }
        /// <summary>
        /// 生成静态文件
        /// </summary>
        /// <param name="control">控件对象</param>
        /// <returns></returns>
        public string RenderView(Control control)
        {
            StringWriter output = new StringWriter();
            this.m_pageHolder.Controls.Add(control);
            HttpContext.Current.Server.Execute(this.m_pageHolder, output, true);
            return output.ToString();
        }
    }
}
